package com.mrjy.common.qtz;

import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import com.mrjy.share.bo.IShareMemberBo;

/**
 * 月底统计分销推荐人数-并发送短信
 * @author Administrator
 *
 */
public class MemberSettlementTimeTask extends TimerTask {

	//private ServletContext context = null;
	
	public static Timer timer = new Timer();
	
	public MemberSettlementTimeTask() {
		
	}
	

	
	@Override
	public void run() {
//		ApplicationContext ac1 =WebApplicationContextUtils.getRequiredWebApplicationContext(context);
//		IUserInfoBo userInfoBo = (IUserInfoBo) ac1.getBean(IUserInfoBo.class);
		
		try {
			WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
			IShareMemberBo shareMemberBo = wac.getBean(IShareMemberBo.class);			
			shareMemberBo.countShareMember();
			 Calendar cale = Calendar.getInstance();
			 cale.set(Calendar.MONTH, cale.get(Calendar.MONTH) + 1);
			 cale.set(Calendar.DAY_OF_MONTH, 1);
			 cale.set(Calendar.HOUR_OF_DAY, 0);
			 cale.set(Calendar.MINUTE, 0);
			 cale.set(Calendar.SECOND, 0);
			 System.out.println("下次执行的时间："+ cale.getTime());			
			 timer.schedule(new MemberSettlementTimeTask(), cale.getTime());
			//context.log("会员状态检查成功");	
		} catch (Exception e) {
			e.printStackTrace();
			//context.log("会员状态检查失败");
		
		}
	}
	
	
	

}
